/**
 * Created by Administrator on 2017/3/2.
 */
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
import { Jsonp, URLSearchParams,Response } from '@angular/http';
import { Observable }   from 'rxjs/observable';
import 'rxjs/add/operator/catch';

@Injectable()
export class UsereditService {
  constructor(private jsonp: Jsonp) {
  }

  public statu = '';
  private showfrom: boolean;

  useredit() {
    let wikiUrl = 'http://api.pinwu.net/site/personal';
    let params = new URLSearchParams();
    params.set('callback', 'JSONP_CALLBACK');

    return this.jsonp
      .get(wikiUrl, {search: params})
      .map((res: Response) => {
        let result = res.json();
        console.log(result);
        return result;
      });
  }
  revise(type:string,username:string,pwd:string,repwd:string,language:string,vocation:string,company:string,address:string){
    let reviseUrl = 'http://api.pinwu.net/site/personal';
    let params = new URLSearchParams();
    params.set('address', address);
    params.set('company', company);
    params.set('vocation', vocation);
    params.set('language', language);
    params.set('repwd', repwd);
    params.set('pwd', pwd);
    params.set('username', username);
    params.set('type', type);
    params.set('callback', 'JSONP_CALLBACK');

    return this.jsonp
      .get(reviseUrl, {search: params})
      .map((res: Response) => {
        let result = res.json();
        console.log(result);
        return result;
      });
  }
}
